package cn.edu.hyit.hjq.volunteems.backend.utils;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.*;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import java.awt.image.BufferedImage;

public class QrCodeUtil {
    public static BufferedImage generateQrCodeImage(String content, int width, int height) throws Exception {
        BitMatrix bitMatrix = new MultiFormatWriter().encode(
                content, BarcodeFormat.QR_CODE, width, height);
        return MatrixToImageWriter.toBufferedImage(bitMatrix);
    }
}
